﻿//创建时间: 2010-12-10
//创建作者: 李 城
//功能说明: 评论信息查看
//最后修改: 2010-12-10

using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using TRPOP.Common;
using TRPOP.CMS.Web.UI;


using TRPOP.CMS.Business;
using TRPOP.CMS.Model;
using System.Collections;

namespace TRPOP.CMS.Web.Admin
{
    public partial class Recomment_save : BaseAdmin
    {
        #region 当前页面权限验证
        protected override void SubPageInit()
        {
            base.m_strPagePermissionExtraKey = "Plugin_comment";
        }
        #endregion

        #region 页面变量
        protected string m_Title = "审核评论";
        protected string m_strRefer = "Recomment_list.aspx";
        protected int intRecId = 0;
        protected RecomManage mRecomManage = new RecomManage();
        protected RecomContentManage mRecomContentManage = new RecomContentManage();
        protected string m_ConfigTypeKey = "Recomment";
        #endregion

        #region 页面事件

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadBase();
            }
        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            int.TryParse(GetRequestViewState("id"), out intRecId);
            m_strRefer = GetRequestViewState("Refer");
            RecomInfo oRecomInfo = mRecomManage.GetInfoById(intRecId);
            RecomContentInfo oRecomContentInfo = mRecomContentManage.GetInfoById(intRecId);
            if (oRecomInfo != null && oRecomContentInfo != null)
            {
                oRecomInfo.Name = txtName.Text;
                oRecomInfo.Detail = txtDetail.Text;
                oRecomContentInfo.IsAudit = true;
                if (mRecomManage.Save(oRecomInfo) == EnumSubmitResult.Success)
                {
                    base.SaveLog(Plugin.LogKeys.OperObject.PluginOper, Plugin.LogKeys.OperResult.EditSubmit, m_ConfigTypeKey);
                    SubmitAlertAndThisNewLocation(mRecomContentManage.Save(oRecomContentInfo), m_strRefer);
                }
            }
            else
            {
                Alert("请通过正确的途径进入本页面");
                return;
            }
        }
        protected void btnNotOK_Click(object sender, EventArgs e)
        {
            int.TryParse(GetRequestViewState("id"), out intRecId);
            m_strRefer = GetRequestViewState("Refer");
            RecomInfo oRecomInfo = mRecomManage.GetInfoById(intRecId);
            RecomContentInfo oRecomContentInfo = mRecomContentManage.GetInfoById(intRecId);
            if (oRecomInfo != null && oRecomContentInfo != null)
            {
                oRecomInfo.Name = txtName.Text;
                oRecomInfo.Detail = txtDetail.Text;
                oRecomContentInfo.IsAudit = false;
                if (mRecomManage.Save(oRecomInfo) == EnumSubmitResult.Success)
                {
                    SubmitAlertAndThisNewLocation(mRecomContentManage.Save(oRecomContentInfo), m_strRefer);
                }
            }
            else
            {
                Alert("请通过正确的途径进入本页面");
                return;
            }
        }
        

        #endregion

        #region 页面方法

        public void LoadBase()
        {
            btnSubmit.Enabled = SYSConfig.RecommentConfigerInfo.EnableAudit;
            int.TryParse(InitRequestViewState("id"), out intRecId);
            if (intRecId <= 0)
            {
                Alert("请通过正确的途径进入本页面");
                base.ExecuteJs("window.location.href='" + m_strRefer + "'");
                return;
            }
            RecomInfo oRecomInfo = mRecomManage.GetInfoById(intRecId);
            txtName.Text = oRecomInfo.Name;
            txtDetail.Text = oRecomInfo.Detail;
            string strRefer = TRPOP.Common.RequestHelper.GetUrlReferrer().ToLower();
            m_strRefer = strRefer.Contains("Recomment_list.aspx") ? strRefer : m_strRefer;
            InitPageViewState("Refer", m_strRefer);
        }
        #endregion
    }
}
